package exercise.day07;

import java.util.Scanner;

public class CalAirPrice {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //头等舱，经济舱，商务舱
        //5-10月旺季 11-4淡季
        //打折
        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int veg = scan.nextInt();
        System.out.println("请输入月份：");
        int moonth = scan.nextInt();
        System.out.println("请输入金额：");
        double price = scan.nextDouble();
        double finalPrice = cal(veg, moonth, price);
        System.out.println("机票的最终价格："+finalPrice);


//        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
//        int veg = scan.nextInt();
//        System.out.println("请输入月份：");
//        int moonth = scan.nextInt();
//        System.out.println("请输入金额：");
//        double price = scan.nextDouble();
//        double finalPrice = calAirPrice(veg, moonth,price);
//        if(finalPrice!=-1){
//            System.out.println("机票的最终价格："+finalPrice);
//        }

    }

    public static double cal(int veg, int moonth, double price) {
        double finalPrice = 0.0;
        if (veg > 3 || veg < 1) {
            System.out.println("舱输入错误");
            return -1;
        } else if (moonth > 12 || moonth < 1) {
            System.out.println("月份输入错误");
            return -1;
        } else if (price < 0) {
            System.out.println("金额输入错误");
            return -1;
        }

        if (moonth >= 5 && moonth <= 10) {
            switch (veg) {
                case 1:
                    price *= 0.9;
                    break;
                case 2:
                    price *= 0.85;
                    break;
                case 3:
                    price *= 0.65;
                    break;
            }
        } else {
            switch (veg) {
                case 1:
                    price*=0.7;
                    break;
                case 2:
                    price *= 0.60;
                    break;
                case 3:
                    price *= 0.6;
                    break;
            }
        }
        finalPrice=price;
        return finalPrice;
    }

        public static double calAirPrice ( int veg, int moonth, double price){
            double finalPrice = 0.0;
            if (veg > 3 || veg < 1) {
                System.out.println("舱位输入错误");
                return -1;
            }
            if (moonth < 1 || moonth > 12) {
                System.out.println("月份输入错误");
                return -1;
            }
            switch (veg) {
                case 1:
                    if (moonth >= 5 && moonth <= 10) {
                        price *= 0.9;
                    } else {
                        price *= 0.7;
                    }
                    break;
                case 2:
                    if (moonth >= 5 && moonth <= 10) {
                        price *= 0.85;
                    } else {
                        price *= 0.65;
                    }
                    break;
                case 3:
                    if (moonth >= 5 && moonth <= 10) {
                        price *= 0.8;
                    } else {
                        price *= 0.6;
                    }
                    break;

            }
            finalPrice = price;
            return finalPrice;
        }



}